package cj.com.chabaike.bll;

import android.content.Context;
import android.util.Log;

import java.util.List;

import cj.com.chabaike.dao.FetchJSONDAO;
import cj.com.chabaike.dao.SharedPerfomentDAO;
import cj.com.chabaike.entity.HomeData;

/**
 * Created by Administrator on 2015/8/1.
 * 这个服务类集成了数据接入层所有的方法
 */


public class RWServer {
    static SharedPerfomentDAO spd;
    static FetchJSONDAO fetchJSONDAO;
    static RWServer rws = new RWServer();

    private RWServer() {


    }

    public static RWServer getInstance(Context applicationContext) {
        // TODO Auto-generated method stub
        spd = SharedPerfomentDAO.getInstance(applicationContext);
        fetchJSONDAO = FetchJSONDAO.getFetchJSONDAOInstance();
        return rws;
    }

    public static boolean isFirstUse() {

        return spd.getValue("isFirst").equals("0");
    }

    public void setContiueUse() {
        spd.putValue("isFirst", "1");

    }

    public void putSpValue(String key, String value) {

        spd.putValue(key, value);
    }

    public String getSpValue(String key) {
        return spd.getValue(key);
    }


    public HomeData getHomeData(String url, FetchJSONDAO.ResultBack resultBack) {

        //Log.e("RWServer", "getHomeData..........");
        return fetchJSONDAO.getHomeData(url, resultBack);

    }

    public void  getNewsData(String url, FetchJSONDAO.NewsDataResultBack newsDataResultBack) {

        //Log.e("RWServer", "getHomeData..........");
        fetchJSONDAO.getNewsData(url, newsDataResultBack);

    }


    public void  getSeachData(String url, FetchJSONDAO.SeachDataResultBack seachDataResultBack) {

        //Log.e("RWServer", "getHomeData..........");
        fetchJSONDAO.getSeachData(url, seachDataResultBack);

    }


    public void  getSpecialData(String url, FetchJSONDAO.SpecialDataResultBack specialDataResultBack) {
        //Log.e("RWServer", "getHomeData..........");
        fetchJSONDAO.getSepcialData(url, specialDataResultBack);

    }

    public void getSepcialDetailData(String url,  FetchJSONDAO.SpecialDataDetailResultBack specialDataDetailResultBack){

        fetchJSONDAO.getSepcialDetailData(url,specialDataDetailResultBack);

    }




    public List<String> ImgurlArarryToList(Object Imgurl) {
        return fetchJSONDAO.ImgurlArarryToList(Imgurl);
    }



}